package com.wei.test.Dao.Impl;

import com.wei.test.Dao.UserDao;
import com.wei.test.Model.TUser;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

public class UserDaoImpl implements UserDao {
    private JdbcTemplate jdbcTemplate;

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate){
        this.jdbcTemplate = jdbcTemplate;
    }

    @Override
    public TUser findByUid(String uid) {
        try{
            String sql = "select * from t_user where uid = '"+uid+"'";
            RowMapper<TUser> rowMapper = new BeanPropertyRowMapper<TUser>(TUser.class);
            TUser data = this.jdbcTemplate.queryForObject(sql,rowMapper);
            return data;
        } catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
